package cn.gson.oasys.services.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import cn.gson.oasys.common.util.PasswordEncoder;
import cn.gson.oasys.dao.user.UserDao;
import cn.gson.oasys.model.entity.user.User;

@Service
public class UserServiceImpl implements IUserService {
	@Autowired
	private UserDao userDao;

	@Override
	public User findByUserNameOrTel(String userNameOrTel) {
		return userDao.findOneUserByUserNameOrTel(userNameOrTel);
	}

	@Override
	public boolean checkPassword(User user, String password) {
		String encodePassword = PasswordEncoder.encodePassword(password);
		if(StringUtils.isEmpty(encodePassword)){
			return false;
		} else {
			return encodePassword.equals(user.getPassword());
		}
	}

}
